import { ref } from "vue";
import { chatItem } from "./types";

export const useEditChatContent = function () {
  const chatItem = ref<chatItem>();
  const curText = ref("");
  function preEdit(item: chatItem) {
    item.visible = true;
    chatItem.value = item;
    curText.value = item.text;
  }
  function confirmEdit(item: chatItem) {
    if (chatItem.value) {
      chatItem.value.text = curText.value;
    }
    item.visible = false;
  }
  return {
    preEdit,
    confirmEdit,
    curText,
  };
};
